<!DOCTYPE html>
<html>
<head>
	<title>遍历dom树</title>
</head>
<body>
	<div id="box">
		<p>我是p</p>
		<ul id="list">
			<li>li1</li>
			<li>li2</li>
			<li>li3</li>
			<li>li4</li>
			<li>li5</li>
		</ul>
		<h1>深度拷贝</h1>
		<h2>
			<p>遍历dom树</p>
		</h2>
	</div>
<script type="text/javascript">
	
var box = document.getElementById('list');
function bianli(box) {
	var child = box.children;		// children只会获取结点,不会获取空白字符
	for (let i = 0; i < child.length; i++) {
		child[i].onclick = function() {
            this.innerText = '你好' + i;
        }
		bianli(child[i]);
	}
}
bianli(box);

</script>
</body>
</html>